﻿using System;
using System.Runtime.Serialization;

/// <summary>
/// Summary description for Class1
/// </summary>
/// 

[DataContract(Namespace = "")]
public class RobotPosition
{
   

    [DataMember]
    public int joint1 { get; set; }
    [DataMember]
    public int joint2 { get; set; }
    [DataMember]
    public int joint3 { get; set; }
    [DataMember]
    public int joint4 { get; set; }
    [DataMember]
    public int joint5 { get; set; }
    [DataMember]
    public int joint6 { get; set; }

    [DataMember]
    public int x { get; set; }

    [DataMember]
    public int y { get; set; }

    [DataMember]
    public int z { get; set; }

    [DataMember]
    public int w { get; set; }

    [DataMember]
    public int p { get; set; }

    [DataMember]
    public int r { get; set; }

    public RobotPosition(RobotJointsValues joints)
    {
        // TODO: Complete member initialization
        this.joint1 = joints.joint1;
        this.joint2 = joints.joint2;
        this.joint3 = joints.joint3;
        this.joint4 = joints.joint4;
        this.joint5 = joints.joint5;
        this.joint6 = joints.joint6;        
    }

    public RobotPosition(RestService.RobotXYZWPRValues xyz)
    {
        this.x = xyz.x;
        this.y = xyz.y;
        this.z = xyz.z;
        this.w = xyz.w;
        this.p = xyz.p;
        this.r = xyz.r;

    }

    public void setJoint(int j, int value)
    {
        switch (j)
        {
            case 1:
                joint1 = value;
                break;
            case 2:
                joint2 = value;
                break;
            case 3:
                joint3 = value;
                break;
            case 4:
                joint4 = value;
                break;
            case 5:
                joint5 = value;
                break;
            case 6:
                joint6 = value;
                break;
            default:
                RobotException re = new RobotException("Joint number " + j + " does not exist");
                throw (re);
        }

    }
}
